package com.example.onedemotest;

import com.example.onedemotest.slice.MainAbilitySlice;
import com.example.onedemotest.slice.TwoSlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;

public class MainAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        //主要的路由
        super.setMainRoute(MainAbilitySlice.class.getName());
        //配置其他的Slice 的路由
        addActionRoute("action.two", TwoSlice.class.getName());

        //启动service
        Intent serviceIntent = new Intent();
        Operation operation=new Intent.OperationBuilder()
                .withAbilityName(ServiceAbility.class.getName())
                .build();
        serviceIntent.setOperation(operation);
        startAbility(serviceIntent);
    }
}
